<template>
	<view>
		<view class="moren" v-if="moren==false">
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				moren: false, //默认1秒后加载
			}
		},
		methods: {

		},
		onLoad() {
			uni.showLoading({
				title: '正在登录中....'
			})
			var _this = this
			// 判断是否认证
			uni.login({
					provider: "weixin",
					success(res) {
						let newCode = res.code
						uni.request({
							// url: "http://192.168.102.80:8080/buildtreasure/person/wxs/login",
							url: "https://www.chuanjianbao.com/buildtreasure/person/wxs/login",
							data: {
								code: newCode
							},
							success(res) {
								// 赋给全局变量userId
								_this.$store.commit('newUserId', res.data.data.userId)
								// 判断是否实名
								_this.$store.commit('newIsRealName', res.data.msg)
								//存储sessionId
								uni.setStorageSync('sessionId', res.data.data.sessionId)
								//用户id存储到本地
								uni.setStorageSync('userId',res.data.data.userId)
								//关注公众号状态存储到本地
								uni.setStorageSync('unionId',res.data.data.unionId)
								// 实名存储本地
								uni.setStorageSync('userIsReal',res.data.msg)
									uni.request({
										url: 'https://www.chuanjianbao.com/buildtreasure/person/get',
										// url: "http://192.168.102.80:8080/buildtreasure/person/get",
										header: { //请求头可自定义
											'Content-Type': 'application/json;charset=UTF-8',
											// 'X-Access-Token': TOKEN
											'Cookie': 'JSESSIONID=' + uni.getStorageSync(
												'sessionId')
										},
										method: 'GET',
										data: {
											userId: res.data.data.userId
										},
										success(res) {
											_this.$store.commit('newSfzh', res.data.data.idCard)
											_this.$store.commit('newIsComplete', res.data.data.isComplete)
											_this.$store.commit('newUsername', res.data.data
												.username)
											_this.$store.commit('newAvatar', res.data.data.avatar)
											_this.$store.commit('newIsRealName', res.data.data.isReal)
											//身份证号存储到本地
											uni.setStorageSync('userSfzh',res.data.data.idCard)
											
											_this.$store.dispatch('getCity')
											_this.$store.dispatch('getEdu')
											_this.$store.dispatch('getPosition')
											_this.$store.dispatch('certs')
											_this.$store.dispatch('tishiInfoList')
											
										}
									})
			
							},
						})
					}
				}),
			// 判断是否认证
			// uni.login({
			// 		provider: "weixin",
			// 		success(res) {
			// 			let newCode = res.code
			// 			uni.request({
			// 				// url: "http://192.168.102.80:8080/buildtreasure/person/wxs/login",
			// 				url: "https://www.chuanjianbao.com/buildtreasure/person/wxs/login",
			// 				data: {
			// 					code: newCode
			// 				},
			// 				success(res) {
			// 					if(res.data.code==200){
			// 						setTimeout(function(){
			// 								that.moren = true
			// 							uni.hideLoading()
			// 							uni.navigateTo({
			// 								url:'../home/home'
			// 							})
			// 						},2000)
			// 					}

			// 				},
			// 			})
			// 		}
			// 	})
			
			setTimeout(function() {
				_this.moren = true
				uni.hideLoading()
				uni.reLaunch({
					url: '../home/home'
				})
			}, 2000)
		}
	}
</script>

<style scoped>
	.moren {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		z-index: 999;
		background-color: #ffffff;
	}
</style>
